package com.jastar.android.game.richman.logic;

import android.content.res.Resources;

import com.jastar.android.game.richman.logic.bean.Player;
import com.jastar.android.game.richman.logic.handler.DiceCallback;
import com.jastar.android.util.Utils;

import java.util.Random;

public class GameManager extends GameDrawing {

    public GameManager(Resources resources, int playerCount, int money) {
        super(resources, playerCount, money);
    }

    public void rollDice(DiceCallback callback) {
        Random rand = new Random();
        for (int i = 0; i < 6; i++) {
            diceResult = rand.nextInt(6) + 1;
            Utils.sleep(FAST_MODE ? 1 : 100);
        }
        Player cPlayer = getCurrentPlayer();
        if (cPlayer.getNextRoll() > 0) {
            diceResult = cPlayer.getNextRoll();
            cPlayer.setNextRoll(0);
        } else {
            diceResult = rand.nextInt(6) + 1;
        }
        callback.onDiceResult(diceResult);
    }

}
